/**
 * Copyright (c) 2014-2015 ENZO 熊强强  (xqenzo@163.com).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 	
 */

package cn.edu.xyc.util;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * Title: Page.java
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2015
 * </p>
 * 
 * @author ENZO E-mail:xqenzo@163.com
 * @date 创建时间：2015年11月9日 下午5:03:09
 * @version 1.0
 */
public class Page<T> implements Serializable {

    private static final long serialVersionUID = 7430190959276847988L;
    
    private List<T> list; // list result of this page
    private int pageNumber; // page number
    private int pageSize; // result amount of this page
    private int totalPage; // total page
    private int totalRow; // total row

    /**
     * Constructor.
     * 
     * @param list
     *            the list of paginate result
     * @param pageNumber
     *            the page number
     * @param pageSize
     *            the page size
     * @param totalPage
     *            the total page of paginate
     * @param totalRow
     *            the total row of paginate
     */
    public Page(List<T> list, int pageNumber, int pageSize, int totalPage,
	    int totalRow) {
	this.list = list;
	this.pageNumber = pageNumber;
	this.pageSize = pageSize;
	this.totalPage = totalPage;
	this.totalRow = totalRow;
    }

    /**
     * Return list of this page.
     */
    public List<T> getList() {
	return list;
    }

    /**
     * Return page number.
     */
    public int getPageNumber() {
	return pageNumber;
    }

    /**
     * Return page size.
     */
    public int getPageSize() {
	return pageSize;
    }

    /**
     * Return total page.
     */
    public int getTotalPage() {
	return totalPage;
    }

    /**
     * Return total row.
     */
    public int getTotalRow() {
	return totalRow;
    }

    public boolean isFirstPage() {
	return pageNumber == 1;
    }

    public boolean isLastPage() {
	return pageNumber == totalPage;
    }
}
